import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author：xz
 * @Date：2023/7/13
 */
public class StringTest {
    public static void main(String[] args) {
//        test13();
//        !debtorAddress.contains("省")
        while(true) {
            Scanner scanner = new Scanner(System.in);
            String sex = scanner.next();
            int i = "M".equals(sex) || "男".equals(sex) ? 0 : 1;
            System.out.println(i);
        }

    }
    public static boolean isPureNumber(String data) {
        String regex = "\\d+";
        return data.matches(regex);
    }
    static void test13(){
        List<String> data = new ArrayList<>();
        String data1 = ".mp3";
        data.add(data1);
        String data2 = ".MP3";

        System.out.println(data2.toLowerCase());
        System.out.println(data1.equalsIgnoreCase(data2));
        System.out.println(data.contains(data2));

    }


    static void test12(){
        String data1 = "1";
        String data2 = "..";

        System.out.println(data1 + " is pure number: " + isPureNumber(data1));
        System.out.println(data2 + " is pure number: " + isPureNumber(data2));

    }

    static void test11(){
        String jobParam = "{'startDate':'2023-01-01','endDate':'2023-01-02'}";
        JSONObject jsonObject = JSONObject.parseObject(jobParam);
        System.out.println(jsonObject);
        String startDateStr = jsonObject.getString("startDate");
        System.out.println(startDateStr);
        String endDateStr = jsonObject.getString("endDate");
        System.out.println(endDateStr);
    }

    static void test1(){
        String defaultJson = "{\"baseTable\":\"hawk_om_accountASomAccount\",\"cols\":[{\"col\":\"omAccount.customer_id\",\"relation\":\"customerName\",\"name\":\"\\u59d4\\u5916\\u65b9\",\"isDefault\":1,\"type\":1,\"select\":1},{\"col\":\"omAccount.customer_state\",\"relation\":\"customerState\",\"name\":\"\\u5ba2\\u6237\\u72b6\\u6001\",\"isDefault\":1,\"type\":1,\"select\":2},{\"col\":\"omAccount.overdue_state\",\"relation\":\"overdueState\",\"name\":\"\\u5ba2\\u6237\\u903e\\u671f\\u72b6\\u6001\",\"isDefault\":1,\"type\":1,\"select\":3},{\"col\":\"omAccount.customer_hand\",\"relation\":\"customerHand\",\"name\":\"\\u624b\\u6b21\",\"isDefault\":1,\"type\":1,\"select\":4},{\"col\":\"omAccount.customer_aging\",\"relation\":\"customerAging\",\"name\":\"\\u8d26\\u9f84\\u6bb5\",\"isDefault\":1,\"type\":1,\"select\":5},{\"col\":\"omAccount.product_id\",\"relation\":\"productType\",\"name\":\"\\u4ea7\\u54c1\\u7c7b\\u578b\",\"isDefault\":1,\"type\":1,\"select\":6},{\"col\":\"omAccount.product_id\",\"relation\":\"productCode\",\"name\":\"\\u4ea7\\u54c1\\u7f16\\u7801\",\"isDefault\":0,\"type\":1,\"select\":7},{\"col\":\"omAccount.overdue_amount\",\"relation\":\"overdueAmount\",\"name\":\"\\u903e\\u671f\\u603b\\u989d\",\"isDefault\":1,\"type\":1,\"select\":8},{\"col\":\"omAccount.is_referral\",\"relation\":\"isReferralText\",\"name\":\"\\u662f\\u5426\\u8f6c\\u8bc9\",\"isDefault\":1,\"type\":1,\"select\":9},{\"col\":\"omAccount.overdue_day\",\"relation\":\"overdueDay\",\"name\":\"\\u903e\\u671f\\u5929\\u6570\",\"isDefault\":1,\"type\":1,\"select\":10},{\"col\":\"omAccount.repay_total\",\"relation\":\"repayTotal\",\"name\":\"\\u8fd8\\u6b3e\\u603b\\u989d\",\"isDefault\":0,\"type\":1,\"select\":11},\t\t{\"col\":\"omAccount.customer_number\",\"relation\":\"customerNumber\",\"name\":\"\\u5ba2\\u6237\\u7f16\\u53f7\",\"isDefault\":1,\"type\":2,\"select\":1},{\"col\":\"debtor.debtor_name\",\"relation\":\"debtorName\",\"name\":\"\\u5ba2\\u6237\\u59d3\\u540d\",\"isDefault\":1,\"type\":2,\"select\":2},{\"col\":\"debtor.id_number\",\"relation\":\"idNumber\",\"name\":\"\\u8bc1\\u4ef6\\u53f7\",\"isDefault\":1,\"type\":2,\"select\":3},{\"col\":\"debtor.gender\",\"relation\":\"genderText\",\"name\":\"\\u6027\\u522b\",\"isDefault\":0,\"type\":2,\"select\":4},{\"col\":\"debtor.nation\",\"relation\":\"nation\",\"name\":\"\\u6c11\\u65cf\",\"isDefault\":0,\"type\":2,\"select\":5},{\"col\":\"debtor.age\",\"relation\":\"age\",\"name\":\"\\u5e74\\u9f84\",\"isDefault\":0,\"type\":2,\"select\":6},{\"col\":\"debtor.province_id\",\"relation\":\"provinceName\",\"name\":\"\\u6237\\u7c4d\\u7701\\u4efd\",\"isDefault\":1,\"type\":2,\"select\":7},{\"col\":\"debtor.city_id\",\"relation\":\"cityName\",\"name\":\"\\u6237\\u7c4d\\u57ce\\u5e02\",\"isDefault\":1,\"type\":2,\"select\":8},{\"col\":\"account.id\",\"relation\":\"accountId\",\"name\":\"\\u6848\\u4ef6ID\",\"isDefault\":1,\"type\":3,\"select\":1},{\"col\":\"account.account_state\",\"relation\":\"accountState\",\"name\":\"\\u6848\\u4ef6\\u72b6\\u6001\",\"isDefault\":1,\"type\":3,\"select\":2},{\"col\":\"account.is_working\",\"relation\":\"isWorking\",\"name\":\"\\u662f\\u5426\\u5728\\u50ac\",\"isDefault\":0,\"type\":3,\"select\":3},{\"col\":\"account.batch_number\",\"relation\":\"batchNumber\",\"name\":\"\\u6279\\u6b21\\u53f7\",\"isDefault\":0,\"type\":3,\"select\":4},{\"col\":\"account.out_amount\",\"relation\":\"outAmount\",\"name\":\"\\u59d4\\u6848\\u91d1\\u989d\",\"isDefault\":1,\"type\":3,\"select\":5},{\"col\":\"accountResult.repay_amount\",\"relation\":\"repayAmount\",\"name\":\"\\u5df2\\u8fd8\\u91d1\\u989d\",\"isDefault\":1,\"type\":3,\"select\":6},{\"col\":\"account.out_date\",\"relation\":\"outDate\",\"name\":\"\\u59d4\\u6848\\u65e5\\u671f\",\"isDefault\":0,\"type\":3,\"select\":7},{\"col\":\"account.due_date\",\"relation\":\"dueDate\",\"name\":\"\\u5230\\u671f\\u65e5\\u671f\",\"isDefault\":0,\"type\":3,\"select\":8},{\"col\":\"account.over_date\",\"relation\":\"overDate\",\"name\":\"\\u7ed3\\u675f\\u65e5\\u671f\",\"isDefault\":0,\"type\":3,\"select\":9},{\"col\":\"user.org_id\",\"relation\":\"orgName\",\"name\":\"\\u6240\\u5c5e\\u673a\\u6784\",\"isDefault\":1,\"type\":3,\"select\":10},\t\t{\"col\":\"account.user_id\",\"relation\":\"userName\",\"name\":\"\\u8ddf\\u8fdb\\u4eba\\u5458\",\"isDefault\":1,\"type\":3,\"select\":11},\t\t{\"col\":\"account.user_id\",\"relation\":\"customerPortrait\",\"name\":\"\\u5ba2\\u6237\\u753b\\u50cf\",\"isDefault\":0,\"type\":3,\"select\":12},\t\t{\"col\":\"account.user_id\",\"relation\":\"customerLabel\",\"name\":\"\\u5ba2\\u6237\\u6807\\u7b7e\",\"isDefault\":0,\"type\":3,\"select\":13},\t\t{\"col\":\"account.out_amount\",\"relation\":\"repayRate\",\"name\":\"\\u56de\\u6b3e\\u7387\",\"isDefault\":0,\"type\":3,\"select\":14}]}";
        Map map = JSONObject.parseObject(defaultJson, Map.class);
        List<Map<Object, Object>> cols = (List<Map<Object, Object>>) map.get("cols");
        map.put("cols", cols);
        System.out.println(map);
    }

    static void test2(){
        String str = "fx2307200001";
        String str2 = "wwff2307200999";
//        Integer integer1 = Integer.valueOf(str);
//        Integer integer2 = Integer.valueOf(str2);
//        integer1 = integer1 + 1;
//        integer2 = integer2 + 1;
//        System.out.println(String.format("%04d",integer1));
//        System.out.println(String.format("%04d",integer2));
        String substring = str.substring(str.length() - 4);
        String substring2 = str2.substring(str2.length() - 4);
        System.out.println(substring);
        System.out.println(substring2);
    }

    static void test3(){
        String str = "fx2307200001";
        BigDecimal bigDecimal = new BigDecimal(str);
    }

    static void test4(){
        String str = "test/利息-98789/Snipaste_2023-09-12_09-31-24.png";
        Pattern pattern = Pattern.compile("([^/]+)");
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            System.out.println(matcher.group(1));  // 输出: "利息-98789"
        }
    }

    static void test5(){
        String str = "利息-98789";
        System.out.println(Arrays.toString(str.split("[_-]")));

    }

    static void test6(){
        // 偶数女、奇数男
        String idnumber = "430981200108031845";
        String str = "3";
        String str1 = "4";
        int i = Integer.parseInt(idnumber.substring(16,17));
//        System.out.println(i);
        System.out.println(i % 2 == 1? 0 : 1);

    }

    static void test7(){
        // 偶数女、奇数男
        String idnumber = "北京市天坛";
        if (!idnumber.contains("省") && !idnumber.contains("市")) {
            System.out.println("没有省市");
        }

    }

    static void test8(){
        List<String> list1 = Arrays.asList("apple", "banana", "orange");
        List<String> list2 = Arrays.asList("apple", "grape", "pineapple");
        List<String> list3 = Arrays.asList("pear", "grape", "kiwi");

        // 判断list1和list2是否有相同元素
        boolean isEqual1 = list1.stream().anyMatch(list2::contains);
        System.out.println("list1 and list2 are equal: " + isEqual1);

        // 判断list1和list3是否有相同元素
        boolean isEqual2 = list1.stream().anyMatch(list3::contains);
        System.out.println("list1 and list3 are equal: " + isEqual2); // 输出
    }

    static void test9(){
        String debtorAddress = "内蒙街古金山二社9号";
        if (!debtorAddress.matches(".*[省市区乡镇县村屯街道路].*")) {
            System.out.println("没有省市");
        }
        System.out.println("是地址");
    }
    static void test10(){
        List<String> list = new ArrayList<>();
        list.add("赵云");
        list.add("黄忠");
        list.add("马超");
        list.add("关羽");

        System.out.println(list);
        list.remove("张飞");
        System.out.println(list);
        list.add("zf");
        System.out.println(list);
    }
}
